//
//  PushView.m
//  NewPro
//
//  Created by 何荧红 on 2018/10/9.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "PushView.h"
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/QQApiInterfaceObject.h>
#import "WXApi.h"
#import "POSActivationVC.h"
#import "TraditionPOSVC.h"

@interface PushView ()
@property (nonatomic, assign) NSInteger pushtype;

@property (nonatomic, strong) UIView *shareView;
@end

@implementation PushView

- (instancetype)initWithCashbackAlertWithType:(NSInteger )type{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2f];
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        [self CashbackAlertWithType:type];
    }
    return self;
}
- (void)CashbackAlertWithType:(NSInteger )type{
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 190)/2, (SCREEN_HEIGHT - 110)/2 - iPhoneX_Top, 190, 110)];
    bgview.layer.cornerRadius = 2;
    bgview.backgroundColor = UIColor.whiteColor;
    [self addSubview:bgview];
    UIImageView *im = [[UIImageView alloc] init];
    im.image = [UIImage imageNamed:@"yhasuccess"];
    [bgview addSubview:im];
    
    UILabel *title = [[UILabel alloc] init];
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    title.textColor = BLUECOLOR;
    [bgview addSubview:title];
    
    UILabel *msg = [[UILabel alloc] init];
    msg.textAlignment = NSTextAlignmentCenter;
    msg.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:12];
    msg.textColor = [UIColor colorWithHexString:@"666666"];
    [bgview addSubview:msg];
    
    [im mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgview);
        make.width.height.mas_equalTo(35);
        make.top.mas_equalTo(10);
    }];
    
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgview);
        make.height.mas_equalTo(14);
        make.top.equalTo(im.mas_bottom).offset(10);
        make.left.right.mas_equalTo(0);
    }];
    
    [msg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgview);
        make.height.mas_equalTo(12);
        make.top.equalTo(title.mas_bottom).offset(14);
        make.left.right.mas_equalTo(0);
    }];
    if (type == 0) {
        title.text = @"提交成功";
        msg.text = @"请在调整记录里查看审核状态";
    }
    if (type == 1) {
        title.text = @"已同意";
        msg.text = @"请在我接收的里查看状态";
    }
    if (type == 2) {
        title.text = @"已拒绝";
        msg.text = @"请在我接收的里查看状态";
    }
    UIButton *bgButton = [[UIButton alloc]init];
    [bgButton addTarget:self action:@selector(CashbackbgClik) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:bgButton];
    [bgButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}
- (void)CashbackbgClik{
    if (self.alertsureBlock) self.alertsureBlock();
}
- (instancetype)initWithShareView{
    self = [super init];
    if (self) {
        self.hidden = YES;
        self.pushtype = 2;
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        [self CleanShareView];
    }
    return self;
}
- (instancetype)initWithMyRedenvelopes{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(SCREEN_WIDTH/2 - 70, SCREEN_HEIGHT/2 - 140 - iPhoneX_Top, 140, 140);
        self.backgroundColor = [UIColor clearColor];
        [self ClerateMyRedenvelopes];
    }
    return self;
}
- (void)ClerateMyRedenvelopes{
    UIImageView *bgimg = [[UIImageView alloc]init];
    bgimg.image = [UIImage imageNamed:@"红包列表弹窗"];
    [self addSubview:bgimg];
    [bgimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(self.mas_top);
        make.width.mas_equalTo(64);
        make.height.mas_equalTo(75);
    }];
    
    UILabel *messagelab = [[UILabel alloc]init];
    messagelab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
    messagelab.textColor = [UIColor colorWithHexString:@"888888"];
    messagelab.text = @"您暂时没有红包哦~";
    [self addSubview:messagelab];
    [messagelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(bgimg.mas_bottom).offset(14);
        make.height.mas_equalTo(15);
    }];
}
- (instancetype)initWithFenRunWithString:(NSString *)string{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2f];
        [self ClertFenRunWithString:string];
    }
    return self;
}
- (void)ClertFenRunWithString:(NSString *)string{
    UIButton *delete = [[UIButton alloc]init];
    [delete setBackgroundImage:[UIImage imageNamed:@"closeBtn"] forState:UIControlStateNormal];
    [delete addTarget:self action:@selector(fenrunRemoveView) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:delete];
    [delete mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(20);
        make.top.equalTo(self.mas_top).offset((SCREEN_HEIGHT - 130)/2 - iPhoneX_Top - 80);
        make.right.equalTo(self.mas_right).offset(-14);
    }];
    UIView *alert = [[UIView alloc]init];
    alert.backgroundColor = [UIColor whiteColor];
    [self addSubview:alert];
    [alert mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(SCREEN_WIDTH - 28);
        make.height.mas_equalTo(110);
        make.centerX.equalTo(self);
        make.top.equalTo(delete.mas_bottom);
    }];
    
    UILabel *message = [[UILabel alloc]init];
    message.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
    message.textColor = [UIColor colorWithHexString:@"333333"];
    message.text = [NSString stringWithFormat:@"预约提现金额%@元于30天内到账",string];
    [alert addSubview:message];
    [message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(alert);
        make.top.equalTo(alert.mas_top).offset(23);
        make.height.mas_equalTo(14);
    }];
    
    
    UIButton *remmm = [[UIButton alloc]init];
    remmm.layer.masksToBounds = YES;
    remmm.layer.cornerRadius = 5;
    remmm.backgroundColor = [UIColor colorWithHexString:@"0CA6F0"];
    remmm.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
    [remmm setTitle:@"确定" forState:UIControlStateNormal];
    [remmm setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [remmm addTarget:self action:@selector(fenrunRemove) forControlEvents:UIControlEventTouchUpInside];
    [alert addSubview:remmm];
    [remmm mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
        make.top.equalTo(message.mas_bottom).offset(25);
        make.centerX.equalTo(alert);
    }];
}
- (void)fenrunRemoveView{
    [self removeFromSuperview];
}
- (void)fenrunRemove{
    [self removeFromSuperview];
    if (self.alertsureBlock) self.alertsureBlock();
}
- (instancetype)initWithChooseAlert{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor clearColor];
        [self CreateDefault];   
    }
    return self;
}
- (instancetype)initWithChooseAlertType:(NSInteger)type{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor clearColor];
        [self CreateChooseType:type];
    }
    return self;
}
- (void)CreateChooseType:(NSInteger)type{
    UIView *alert = [[UIView alloc]init];
    alert.layer.masksToBounds = YES;
    alert.layer.cornerRadius = 10;
    alert.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.8];
    [self addSubview:alert];
    [alert mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(SCREEN_WIDTH - 106);
        make.height.mas_equalTo(114);
    }];
    UILabel *messagelab = [[UILabel alloc]init];
    messagelab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    messagelab.textColor = [UIColor colorWithHexString:@"ffffff"];
    if (type == 0) {
        messagelab.text = @"您输入的信息有误!";
    }
    if (type == 1) {
        messagelab.text = @"划拨成功!";
    }
    [alert addSubview:messagelab];
    [messagelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(alert.mas_centerX);
        make.top.equalTo(alert.mas_top).offset(21);
        make.height.mas_equalTo(18);
    }];
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
    [alert addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(messagelab.mas_bottom).offset(20);
        make.left.equalTo(alert.mas_left);
        make.right.equalTo(alert.mas_right);
        make.height.mas_equalTo(1);
    }];
    UIButton *selebutton = [[UIButton alloc]init];
    [selebutton addTarget:self action:@selector(ChooseType:) forControlEvents:UIControlEventTouchUpInside];
    selebutton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    [selebutton setTitleColor:[UIColor colorWithHexString:@"ffffff"] forState:UIControlStateNormal];
    [alert addSubview:selebutton];
    [selebutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(alert.mas_left);
        make.top.equalTo(line.mas_bottom);
        make.bottom.equalTo(alert.mas_bottom);
        make.right.equalTo(alert.mas_right);
    }];
    if (type == 0) {
        [selebutton setTitle:@"重新输入" forState:UIControlStateNormal];
    }
    if (type == 1) {
        [selebutton setTitle:@"完成" forState:UIControlStateNormal];
    }
}
- (void)ChooseType:(UIButton *)button{
    if (self.alertTypeBlock) self.alertTypeBlock();
}
- (void)CreateDefault{
    UIView *choose = [[UIView alloc]init];
    choose.layer.masksToBounds = YES;
    choose.layer.cornerRadius = 10;
    choose.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.8];
    [self addSubview:choose];
    [choose mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(270);
        make.height.mas_equalTo(234);
    }];
    UILabel *message = [[UILabel alloc]init];
    message.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    message.textColor = [UIColor colorWithHexString:@"ffffff"];
    message.text = @"请输入合伙人信息";
    [choose addSubview:message];
    [message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(choose.mas_top).offset(25);
        make.centerX.equalTo(choose.mas_centerX);
        make.height.mas_equalTo(17);
    }];
    for (NSInteger i = 0; i < 2; i++) {
        UIView *bgView = [[UIView alloc]init];
        bgView.backgroundColor = [UIColor colorWithHexString:@"666666"];
        [choose addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            if (i == 0) {
                make.top.equalTo(message.mas_bottom).offset(25);
            }else{
                make.top.equalTo(message.mas_bottom).offset(70);
            }
            make.centerX.mas_equalTo(choose.mas_centerX);
            make.height.mas_equalTo(35);
            make.width.mas_equalTo(190);
        }];
        UITextField *text = [[UITextField alloc]init];
        text.tag = 2313 + i;
        [text addTarget:self action:@selector(textFieldDidEditing:) forControlEvents:UIControlEventEditingChanged];
        text.backgroundColor = [UIColor clearColor];
        text.textColor = [UIColor whiteColor];
        text.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
        NSString *holderText = @"";
        if (i == 0) {
            holderText = @"请输入合伙人注册姓名";
        }else{
            holderText = @"请输入合伙人注册手机号";
        }
        NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:holderText];
        [placeholder addAttribute:NSForegroundColorAttributeName
                            value:[UIColor colorWithHexString:@"fefefe"]
                            range:NSMakeRange(0, holderText.length)];
        [placeholder addAttribute:NSFontAttributeName
                            value:[UIFont fontWithName:@"PingFang-SC-Medium" size:14]
                            range:NSMakeRange(0, holderText.length)];
        text.attributedPlaceholder = placeholder;
        [choose addSubview:text];
        [text mas_makeConstraints:^(MASConstraintMaker *make) {
            if (i == 0) {
                make.top.equalTo(message.mas_bottom).offset(25);
            }else{
                make.top.equalTo(message.mas_bottom).offset(70);
            }
            make.left.equalTo(bgView.mas_left).offset(10);
            make.height.mas_equalTo(35);
            make.width.mas_equalTo(180);
        }];
        UIButton *selet = [[UIButton alloc]init];
        [selet addTarget:self action:@selector(ButtonClik:) forControlEvents:UIControlEventTouchUpInside];
        selet.backgroundColor = [UIColor clearColor];
        selet.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
        [selet setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        if (i == 0) {
            [selet setTitle:@"取消" forState:UIControlStateNormal];
        }
        if (i == 1) {
            [selet setTitle:@"确认" forState:UIControlStateNormal];
        }
        [choose addSubview:selet];
        [selet mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(choose.mas_top).offset(177);
            make.left.equalTo(choose.mas_left).offset(135 * i);
            make.width.mas_equalTo(135);
            make.height.mas_equalTo(56);
        }];
    }
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
    [choose addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(choose.mas_top).offset(177);
        make.centerX.equalTo(choose.mas_centerX);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(270);
    }];
    UIView *line2 = [[UIView alloc]init];
    line2.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
    [choose addSubview:line2];
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(choose.mas_top).offset(178);
        make.centerX.equalTo(choose.mas_centerX);
        make.height.mas_equalTo(56);
        make.width.mas_equalTo(1);
    }];
}
- (void)textFieldDidEditing:(UITextField *)textField{
    if (textField.tag - 2313 == 0) {
        self.choosename = textField.text;
    }
    if (textField.tag - 2313 == 1) {
        self.choosephone = textField.text;
    }
}
- (void)ButtonClik:(UIButton *)button{
    
    if ([button.titleLabel.text isEqualToString:@"取消"]) {
        
        UITextField *tf1 = (UITextField *)[self viewWithTag:2313];
        UITextField *tf2 = (UITextField *)[self viewWithTag:2314];
        tf1.text = nil;
        tf2.text = nil;
        [self removeFromSuperview];
    }
    if ([button.titleLabel.text isEqualToString:@"确认"]) {
        if (self.alertsureBlock) self.alertsureBlock();
    }
}

- (instancetype)initWithAlertView:(NSString *)message info:(NSString *)info type:(NSInteger)type{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, -iPhoneX_Top, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor clearColor];
        [self CleanWithAlertView:message info:info type:type];
    }
    return self;
}
- (instancetype)initWithSuccessAlertView{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, -iPhoneX_Top, SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor clearColor];
        [self CleanWithSuccessAlert];
    }
    return self;
}
- (void)CleanWithSuccessAlert{
    UIView *alert = [[UIView alloc]init];
    alert.layer.masksToBounds = YES;
    alert.layer.cornerRadius = 10;
    alert.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.8];
    [self addSubview:alert];
    [alert mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(SCREEN_WIDTH - 106);
        make.height.mas_equalTo(114);
    }];
    UILabel *messagelab = [[UILabel alloc]init];
    messagelab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    messagelab.textColor = [UIColor colorWithHexString:@"ffffff"];
    messagelab.text = @"划拨成功!";
    [alert addSubview:messagelab];
    [messagelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(alert.mas_centerX);
        make.top.equalTo(alert.mas_top).offset(21);
        make.height.mas_equalTo(18);
    }];
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
    [alert addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(messagelab.mas_bottom).offset(20);
        make.left.equalTo(alert.mas_left);
        make.right.equalTo(alert.mas_right);
        make.height.mas_equalTo(1);
    }];
    UIButton *selebutton = [[UIButton alloc]init];
    selebutton.tag = 3453;
    [selebutton addTarget:self action:@selector(alertButtonClik:) forControlEvents:UIControlEventTouchUpInside];
    selebutton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    [selebutton setTitleColor:[UIColor colorWithHexString:@"ffffff"] forState:UIControlStateNormal];
    [alert addSubview:selebutton];
    [selebutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(alert.mas_left);
        make.top.equalTo(line.mas_bottom);
        make.bottom.equalTo(alert.mas_bottom);
        make.right.equalTo(alert.mas_right);
    }];
    [selebutton setTitle:@"完成" forState:UIControlStateNormal];
}
- (void)CleanWithAlertView:(NSString *)message info:(NSString *)info type:(NSInteger)type{
    UIView *alert = [[UIView alloc]init];
    alert.layer.masksToBounds = YES;
    alert.layer.cornerRadius = 10;
    alert.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.8];
    [self addSubview:alert];
    [alert mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(SCREEN_WIDTH - 106);
        make.height.mas_equalTo(150);
    }];
    UILabel *messagelab = [[UILabel alloc]init];
    messagelab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
    messagelab.textColor = [UIColor colorWithHexString:@"ffffff"];
    messagelab.text = message;
    [alert addSubview:messagelab];
    [messagelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(alert.mas_centerX);
        make.top.equalTo(alert.mas_top).offset(21);
        make.height.mas_equalTo(18);
    }];
    UILabel *infolab = [[UILabel alloc]init];
    infolab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
    infolab.textColor = [UIColor colorWithHexString:@"ffffff"];
    infolab.text = info;
    [alert addSubview:infolab];
    [infolab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(alert.mas_centerX);
        make.top.equalTo(messagelab.mas_bottom).offset(20);
        make.height.mas_equalTo(17);
    }];
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
    [alert addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(infolab.mas_bottom).offset(20);
        make.left.equalTo(alert.mas_left);
        make.right.equalTo(alert.mas_right);
        make.height.mas_equalTo(1);
    }];
    if (type == 0) {
        for (NSInteger i = 0; i < 2; i++) {
            UIButton *selebutton = [[UIButton alloc]init];
            selebutton.tag = 3452 + i;
            [selebutton addTarget:self action:@selector(alertButtonClik:) forControlEvents:UIControlEventTouchUpInside];
            selebutton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
            [selebutton setTitleColor:[UIColor colorWithHexString:@"ffffff"] forState:UIControlStateNormal];
            [alert addSubview:selebutton];
            [selebutton mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(alert.mas_left).offset((((SCREEN_WIDTH - 106) - 1)/2 + 1) * i);
                make.top.equalTo(line.mas_bottom);
                make.bottom.equalTo(alert.mas_bottom);
                make.width.mas_equalTo(((SCREEN_WIDTH - 106) - 1)/2);
            }];
            if (i == 0) {
                [selebutton setTitle:@"取消" forState:UIControlStateNormal];
            }else if (i == 1){
                [selebutton setTitle:@"确定" forState:UIControlStateNormal];
            }
        }
        UIView *line1 = [[UIView alloc]init];
        line1.backgroundColor = [UIColor colorWithHexString:@"cccccc" alpha:0.6];
        [alert addSubview:line1];
        [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(1);
            make.left.equalTo(alert.mas_left).offset(((SCREEN_WIDTH - 106) - 1)/2);
            make.bottom.equalTo(alert.mas_bottom);
            make.top.equalTo(line.mas_bottom);
        }];
    }else{
        UIButton *selebutton = [[UIButton alloc]init];
        selebutton.tag = 3452;
        [selebutton addTarget:self action:@selector(alertButtonClik:) forControlEvents:UIControlEventTouchUpInside];
        selebutton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
        [selebutton setTitleColor:[UIColor colorWithHexString:@"ffffff"] forState:UIControlStateNormal];
        [alert addSubview:selebutton];
        [selebutton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(alert.mas_left);
            make.top.equalTo(line.mas_bottom);
            make.bottom.equalTo(alert.mas_bottom);
            make.right.equalTo(alert.mas_right);
        }];
        [selebutton setTitle:@"确定" forState:UIControlStateNormal];
    }
}
- (void)alertButtonClik:(UIButton *)button{
    if (button.tag - 3452 == 0) {
        [self removeFromSuperview];
    }
    if (button.tag - 3452 == 1) {
        if (self.alertsureBlock) self.alertsureBlock();
    }
}
- (void)CleanShareView{
    UIButton *bgbutton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - iPhoneX_Bottom)];
    [bgbutton addTarget:self action:@selector(ViewPull) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:bgbutton];
    self.shareView = [[UIView alloc]init];
    self.shareView.backgroundColor = [UIColor colorWithHexString:@"DAE8F0"];
    [self addSubview:self.shareView];
    [self.shareView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(105);
        make.centerX.equalTo(self.mas_centerX);
        make.bottom.equalTo(self.mas_bottom).offset(300);
    }];
    UIScrollView *ScrollView = [[UIScrollView alloc]init];
    ScrollView.backgroundColor = [UIColor clearColor];
    ScrollView.showsVerticalScrollIndicator = NO;
    ScrollView.showsHorizontalScrollIndicator = NO;
    ScrollView.contentSize = CGSizeMake(SCREEN_WIDTH/4 * 4.4, 105);//只是为了它能滑动
    [self.shareView addSubview:ScrollView];
    [ScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.shareView.mas_left);
        make.top.equalTo(self.shareView.mas_top);
        make.right.equalTo(self.shareView.mas_right);
        make.height.mas_equalTo(105);
    }];
    for (NSInteger i = 0; i < 4; i++) {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4 * i, 0, SCREEN_WIDTH/4, 105)];
        button.tag = 1024 + i;
        [button addTarget:self action:@selector(ShareType:) forControlEvents:UIControlEventTouchUpInside];
        [ScrollView addSubview:button];
        
        UIImageView *bgimg = [[UIImageView alloc]init];
        [ScrollView insertSubview:bgimg belowSubview:button];
        [bgimg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(button.mas_centerX);
            make.top.equalTo(ScrollView.mas_top).offset(24);
            make.width.mas_equalTo(40);
            make.height.mas_equalTo(40);
        }];
        UILabel *subshare = [[UILabel alloc]init];
        subshare.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:12];
        subshare.textColor = [UIColor colorWithHexString:@"666666"];
        [ScrollView insertSubview:subshare belowSubview:button];
        [subshare mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(button.mas_centerX);
            make.top.equalTo(bgimg.mas_bottom).offset(7);
        }];
        if (i == 0) {
            subshare.text = @"分享到微信";
            bgimg.image = [UIImage imageNamed:@"分享至微信"];
        }
        if (i == 1) {
            subshare.text = @"分享朋友圈";
            bgimg.image = [UIImage imageNamed:@"分享至朋友圈"];
        }
        if (i == 2) {
            subshare.text = @"分享到QQ";
            bgimg.image = [UIImage imageNamed:@"分享至QQ"];
        }
        if (i == 3) {
            subshare.text = @"分享到空间";
            bgimg.image = [UIImage imageNamed:@"分享至QQ空间"];
        }
    }
}
- (void)ShareType:(UIButton *)button{
    if (button.tag - 1024 == 0) {
        if (!button.selected) {
            WXMediaMessage *message = [WXMediaMessage message];
            message.title = self.name;//主标题
            message.description = self.subtitle;//描述
            [message setThumbData:self.scanQdata];
            
            WXWebpageObject *webobject = [WXWebpageObject object];
            webobject.webpageUrl = self.weburl;
            message.mediaObject = webobject;
            
            SendMessageToWXReq *req = [[SendMessageToWXReq alloc]init];
            req.message = message;
            req.scene = WXSceneSession;
            BOOL status = [WXApi sendReq:req];
            NSLog(@"%d",status);
        }
        button.selected = !button.selected;
    }
    if (button.tag - 1024 == 1) {
        if (!button.selected) {
            WXMediaMessage *message = [WXMediaMessage message];
            message.title = self.name;//主标题
            message.description = self.subtitle;//描述
            [message setThumbData:self.scanQdata];
            
            WXWebpageObject *webobject = [WXWebpageObject object];
            webobject.webpageUrl = self.weburl;
            message.mediaObject = webobject;
            
            SendMessageToWXReq *req = [[SendMessageToWXReq alloc]init];
            req.message = message;
            req.scene = WXSceneTimeline;
            BOOL status = [WXApi sendReq:req];
            NSLog(@"%d",status);
        }
        button.selected = !button.selected;
    }
    if (button.tag - 1024 == 2 || button.tag - 1024 == 3) {
        if (!button.selected) {
            NSString *utf8String = self.weburl;
            NSString *title = self.name;
            NSString *description = self.subtitle;
            QQApiNewsObject *newsObj = [QQApiNewsObject objectWithURL:[NSURL URLWithString:utf8String] title:title description:description previewImageData:self.scanQdata];
//                                        objectWithURL:[NSURL URLWithString:utf8String]
//                                        title:title
//                                        description:description
//                                        previewImageURL:[NSURL URLWithString:previewImageUrl]];
            SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:newsObj];
            if (button.tag - 1024 == 2) {
                //将内容分享到qq
                QQApiSendResultCode sent = [QQApiInterface sendReq:req];
                NSLog(@"%d",sent);
            }
            if (button.tag - 1024 == 3) {
                //将内容分享到qzone
                QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];
                NSLog(@"%d",sent);
            }
        }
        button.selected = !button.selected;
    }
}
- (void)ViewPush:(BOOL)HXC{
    if (self.pushtype == 0 || self.pushtype == 1) {
//        [UIView animateWithDuration:0.3 animations:^{
//            self.frame = CGRectMake(0, iPhoneX_Top + 45, SCREEN_WIDTH, 89);
//        }];
    }
    if (self.pushtype == 2) {
        self.hidden = NO;
        [self.shareView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            if (HXC) {
                make.bottom.equalTo(self.mas_bottom).offset(-iPhoneX_Bottom - (iPhoneX_Top));
            }else{
                
                make.bottom.equalTo(self.mas_bottom).offset(-iPhoneX_Bottom);
            }
            
        }];
        [UIView animateWithDuration:0.3 animations:^{
            [self layoutIfNeeded];
        }];
    }
}
- (void)ViewPull{
    if (self.pushtype == 0 || self.pushtype == 1) {
//        [UIView animateWithDuration:0.3 animations:^{
//            self.frame = CGRectMake(0, - 1000, SCREEN_WIDTH, 89);
//        }];
    }
    if (self.pushtype == 2) {
        self.hidden = YES;
        [self.shareView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_bottom).offset(300);
        }];
        [UIView animateWithDuration:0.3 animations:^{
            [self layoutIfNeeded];
        }];
    }
}



@end
